# from attack_payloads.test_attack1 import AttackPayloads

import argparse
import importlib


# 检验漏洞触发成功与否
# 使用的方法/传递的参数/预期结果
def poc(method, expected, *args):
    msg = exp(method, *args)
    if expected in msg:
        return True
    else:
        return False


def exp(method, *args):
    # 使用特定的method并传入args进行攻击
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--model', type=str, help='chooses which model to use.')
    namespace = parser.parse_args()
    namespace.model = method
    model_filename = "attack_payloads." + namespace.model
    # 根据指定的args.model来导入本地attack_payloads文件夹中的相应args.model + '.py'模块
    # 假设如果args.model = cycle_gan，则导入模块models.cycle_gan_model
    attack_model = importlib.import_module(model_filename)

    expected = attack_model.attack(*args)
    print("exppppppppp", expected)
    return expected
    # 漏洞按照可以做的事情分为三类：readfile,RCE,信息获取(这种一般保存起来供字典爆破/渗透回传)
    # 返回：命令的结果


if __name__ == "__main__":
    # exp("test_attack1", "arg11222333")
    exp("CVE-2017-8917", "localhost:8080", "user()")